
#ifndef __FILESECT_H__
#define __FILESECT_H__

class CFilePackage;
#include <stdio.h>

struct SFileSectInfo
{
	char m_szFileName[128];
	unsigned long m_nOffset;
	unsigned long m_nDataLen;
	int           m_iHashIndex;
	SFileSectInfo()
	{
		m_nOffset = 0;
		m_nDataLen = 0;
		m_iHashIndex = 0;
	}
};

class CFileSect
{
	friend class CFilePackage;

	CFilePackage *m_pOwner;
	SFileSectInfo m_sInfo;
protected:
	CFileSect()
	{

		m_pOwner = 0;
	}
	virtual ~CFileSect()
	{

	}
	int writeData();
	int readData( char * buf );

	int writeInfo();
	int readInfo();

	inline void setOwner( CFilePackage *pOwner )    { m_pOwner = pOwner; }
	inline void setDataLen( unsigned long _len )    { m_sInfo.m_nDataLen = _len; }
	inline void setOffset( unsigned long _offset )  { m_sInfo.m_nOffset = _offset; }
	inline void setFileName( const char *filename ) { sprintf( m_sInfo.m_szFileName, "%s", filename); }

	inline unsigned long getDataLen()               { return m_sInfo.m_nDataLen; }
	inline unsigned long getOffset()                { return m_sInfo.m_nOffset; }
	inline const char *  getFileName()              { return m_sInfo.m_szFileName; }
	inline int           getHashIndex()             { return m_sInfo.m_iHashIndex; }
	inline void          setHashIndex( int _index)  { m_sInfo.m_iHashIndex = _index; }
};

#endif // __FILESECT_H__